<%
    /**
     * ????????
     * edited by amon 2005-8-16
     */
%>
<script>
    var highLineTr = null;
    function highLight(object)
    { 
        highLineTr = object;
        object.style.background="#FFFFCC";
    }

    function highLight4Mouse(object)
    { 
        if(object != highLineTr)
        {
            object.style.background="#CCFFCC";
        }
    }

    function lowLight4Mouse(object)
    { 
        if(object != highLineTr)
        {
            object.style.background=object.oldcolor;
        }
    }

    function lowLight(object)
    { 
        highLineTr = null;
//        alert(object.id + " " +object.oldcolor);
        object.style.background=object.oldcolor;
    } 
    
    function lowLight4Selected(object)
    { 
        object.style.background="#E6F7FF";
    }
</script>
<form name="detailForm" action = "<%= ControllerURL%>">
<%
    logger.debug("  -- 打印记录");
    ItemListArea ilArea = (ItemListArea)request.getAttribute("viewer");
    ValueListHandler valueListHandler  = (ValueListHandler)request.getAttribute("valueListHandler");
    List models = valueListHandler.getOnePage(currPageNum);
    if(columns == null)
    {
        for(int i = 0; i < models.size(); i ++)
        {
            BaseObject bo = (BaseObject)models.get(i);
            List items = ilArea.getItems(request.getContextPath(),bo);
            if(i%2 == 0)
            {
                %>
            <tr  bgcolor="F2F2F2" oldcolor="F2F2F2" id="tr_<%= bo.getIdentity()%>" onmouseout="trHighLightWhenMouseOut('<%= bo.getIdentity()%>')" onmouseover="trLowLightWhenMouseOver('<%= bo.getIdentity()%>')" ondblclick="trhighOrLowLight('<%= bo.getIdentity()%>')">
                <%
            }
            else
            {
                %>
            <tr  bgcolor="FFFFFF" oldcolor="FFFFFF" id="tr_<%= bo.getIdentity()%>" onmouseout="trHighLightWhenMouseOut('<%= bo.getIdentity()%>')" onmouseover="trLowLightWhenMouseOver('<%= bo.getIdentity()%>')" ondblclick="trhighOrLowLight('<%= bo.getIdentity()%>')">
                <%
            }
            for(int j = 0; j < items.size(); j ++)
            {
                Item item = (Item)items.get(j);
                String divStyle = "";
                if(item.getPrinted())
                {
                    divStyle = "style='width:" + this.printItemLength(item) + "px'";
                }
                
//                if(j == 0)
//                    out.print("<td align='center' width='1%'>");
//                else
                    out.print("<td " + FontLayOut.HTML_LAY_OUT_TABS[item.getXLayOut()] + ">");
                %>
                    <% 
                    if(item.getOnClickJSFunc() != null)
                    {
                    %>
                    <div <%= divStyle%>>&nbsp;<a href="#" onmouseover="<%= item.getOnMouseOverJS()%>" onmouseout="hidetip()" onclick = "<%= item.getOnClickJSFunc()%>"><%= item.getText4Html()%></a><%= item.getItemExt()%>&nbsp;</div>
                    <%
                    }
                    else
                    {
                    %>
                    <div <%= divStyle%>  onmouseover="<%= item.getOnMouseOverJS()%>" onmouseout="hidetip()">&nbsp;<%= item.getText4Html()%>&nbsp;</div><%= item.getItemExt()%>
                    <%
                    }
                    %>
                </td>
                <%
            }// for j
            %>
            </tr>    
            <%
        }// for i
        logger.debug("小计");
        List items4SubTotal = ilArea.getSubtotal(request.getContextPath(),models);
        if(items4SubTotal.size() > 0)
        {
            %>
            <tr  bgcolor="#E8F5E7" oldcolor="#E8F5E7" id="tr_subTotal" onmouseout="trHighLightWhenMouseOut('subTotal')" onmouseover="trLowLightWhenMouseOver('subTotal')" ondblclick="trhighOrLowLight('subTotal')">
            <%
            for(int j = 0; j < items4SubTotal.size(); j ++)
            {
                Item item = (Item)items4SubTotal.get(j);
                String divStyle = "";
                    if(item.getPrinted())
                    {
                        divStyle = "style='width:" + this.printItemLength(item) + "px'";
                    }
    //                if(j == 0)
    //                    out.print("<td align='center' width='1%'>");
    //                else
                        out.print("<td " + FontLayOut.HTML_LAY_OUT_TABS[item.getXLayOut()] + ">");
                    %>
                    
                        <% 
                        if(item.getOnClickJSFunc() != null)
                        {
                        %>
                        <div <%= divStyle%>>&nbsp;<a href="#" onmouseover="<%= item.getOnMouseOverJS()%>" onmouseout="hidetip()" onclick = "<%= item.getOnClickJSFunc()%>"><%= item.getText4Html()%></a>&nbsp;</div><%= item.getItemExt()%>
                        <%
                        }
                        else
                        {
                        %>
                        <div <%= divStyle%> onmouseover="<%= item.getOnMouseOverJS()%>" onmouseout="hidetip()">&nbsp;<%= item.getText4Html()%>&nbsp;</div><%= item.getItemExt()%>
                        <%
                        }
                        %>
                    </td>
                    <%
            }// 小计 for 
            %>
            </tr>    
            <%
        }
        logger.debug("合计");
        List items4Total = ilArea.getTotal(request.getContextPath(),valueListHandler.getList());
        if(items4Total.size() > 0)
        {
            %>
            <tr  bgcolor="#E7EBFA"  oldcolor="#E7EBFA" id="tr_total" onmouseout="trHighLightWhenMouseOut('total')" onmouseover="trLowLightWhenMouseOver('total')" ondblclick="trhighOrLowLight('total')">
            <%
            for(int j = 0; j < items4Total.size(); j ++)
            {
                Item item = (Item)items4Total.get(j);
                String divStyle = "";
                    if(item.getPrinted())
                    {
                        divStyle = "style='width:" + this.printItemLength(item) + "px'";
                    }
    //                if(j == 0)
    //                    out.print("<td align='center' width='1%'>");
    //                else
                        out.print("<td " + FontLayOut.HTML_LAY_OUT_TABS[item.getXLayOut()] + ">");
                    %>
                    
                        <% 
                        if(item.getOnClickJSFunc() != null)
                        {
                        %>
                        <div <%= divStyle%>>&nbsp;<a href="#" onmouseover="<%= item.getOnMouseOverJS()%>" onmouseout="hidetip()" onclick = "<%= item.getOnClickJSFunc()%>"><%= item.getText4Html()%></a>&nbsp;</div><%= item.getItemExt()%>
                        <%
                        }
                        else
                        {
                        %>
                        <div <%= divStyle%> onmouseover="<%= item.getOnMouseOverJS()%>" onmouseout="hidetip()">&nbsp;<%= item.getText4Html()%>&nbsp;</div><%= item.getItemExt()%>
                        <%
                        }
                        %>
                    </td>
                    <%
            }//  合计 for 
            %>
            </tr>    
            <%
        }
    }
    else
    {
        for(int i = 0; i < models.size(); i ++)
        {
            BaseObject bo = (BaseObject)models.get(i);
            List items = ilArea.getItems(request.getContextPath(),bo);
            if(i%2 == 0)
            {
                %>
            <tr  bgcolor="F2F2F2" oldcolor="F2F2F2" id="tr_<%= bo.getIdentity()%>" onmouseout="trHighLightWhenMouseOut('<%= bo.getIdentity()%>')" onmouseover="trLowLightWhenMouseOver('<%= bo.getIdentity()%>')" ondblclick="trhighOrLowLight('<%= bo.getIdentity()%>')">
                <%
            }
            else
            {
                %>
            <tr  bgcolor="FFFFFF" oldcolor="FFFFFF" id="tr_<%= bo.getIdentity()%>" onmouseout="trHighLightWhenMouseOut('<%= bo.getIdentity()%>')" onmouseover="trLowLightWhenMouseOver('<%= bo.getIdentity()%>')" ondblclick="trhighOrLowLight('<%= bo.getIdentity()%>')">
                <%
            }
            for(int j = 0; j < columns.length; j ++)
            {
                Item item = (Item)items.get(Integer.parseInt(columns[j]));
                String divStyle = "";
                if(item.getPrinted())
                {
                    divStyle = "style='width:" + this.printItemLength(item) + "px'";
                }
//                if(j == 0)
//                    out.print("<td align='center' width='1%'>");
//                else
                    out.print("<td " + FontLayOut.HTML_LAY_OUT_TABS[item.getXLayOut()] + ">");
                %>
                
                    <% 
                    if(item.getOnClickJSFunc() != null)
                    {
                    %>
                    <div <%= divStyle%>>&nbsp;<a href="#" onmouseover="<%= item.getOnMouseOverJS()%>" onmouseout="hidetip()" onclick = "<%= item.getOnClickJSFunc()%>"><%= item.getText4Html()%></a>&nbsp;</div><%= item.getItemExt()%>
                    <%
                    }
                    else
                    {
                    %>
                    <div <%= divStyle%> onmouseover="<%= item.getOnMouseOverJS()%>" onmouseout="hidetip()">&nbsp;<%= item.getText4Html()%>&nbsp;</div><%= item.getItemExt()%>
                    <%
                    }
                    %>
                </td>
                <%
            }// for j
        }// for i
        logger.debug("小计");
        List items4SubTotal = ilArea.getSubtotal(request.getContextPath(),models);
        if(items4SubTotal.size() > 0)
        {
            %>
            <tr  bgcolor="#E8F5E7" oldcolor="#E8F5E7" id="tr_subTotal" onmouseout="trHighLightWhenMouseOut('subTotal')" onmouseover="trLowLightWhenMouseOver('subTotal')" ondblclick="trhighOrLowLight('subTotal')">
            <%
            for(int j = 0; j < columns.length; j ++)
            {
                Item item = (Item)items4SubTotal.get(Integer.parseInt(columns[j]));
                String divStyle = "";
                    if(item.getPrinted())
                    {
                        divStyle = "style='width:" + this.printItemLength(item) + "px'";
                    }
    //                if(j == 0)
    //                    out.print("<td align='center' width='1%'>");
    //                else
                        out.print("<td " + FontLayOut.HTML_LAY_OUT_TABS[item.getXLayOut()] + ">");
                    %>
                    
                        <% 
                        if(item.getOnClickJSFunc() != null)
                        {
                        %>
                        <div <%= divStyle%>>&nbsp;<a href="#" onmouseover="<%= item.getOnMouseOverJS()%>" onmouseout="hidetip()" onclick = "<%= item.getOnClickJSFunc()%>"><%= item.getText4Html()%></a>&nbsp;</div><%= item.getItemExt()%>
                        <%
                        }
                        else
                        {
                        %>
                        <div <%= divStyle%> onmouseover="<%= item.getOnMouseOverJS()%>" onmouseout="hidetip()">&nbsp;<%= item.getText4Html()%>&nbsp;</div><%= item.getItemExt()%>
                        <%
                        }
                        %>
                    </td>
                    <%
            }// 小计 for 
            %>
            </tr>    
            <%
        }
        logger.debug("合计");
        List items4Total = ilArea.getTotal(request.getContextPath(),valueListHandler.getList());
        if(items4Total.size() > 0)
        {
            %>
            <tr  bgcolor="#E7EBFA"  oldcolor="#E7EBFA" id="tr_total" onmouseout="trHighLightWhenMouseOut('total')" onmouseover="trLowLightWhenMouseOver('total')" ondblclick="trhighOrLowLight('total')">
            <%
            for(int j = 0; j < columns.length; j ++)
            {
                Item item = (Item)items4Total.get(Integer.parseInt(columns[j]));
                String divStyle = "";
                    if(item.getPrinted())
                    {
                        divStyle = "style='width:" + this.printItemLength(item) + "px'";
                    }
    //                if(j == 0)
    //                    out.print("<td align='center' width='1%'>");
    //                else
                        out.print("<td " + FontLayOut.HTML_LAY_OUT_TABS[item.getXLayOut()] + ">");
                    %>
                    
                        <% 
                        if(item.getOnClickJSFunc() != null)
                        {
                        %>
                        <div <%= divStyle%>>&nbsp;<a href="#" onmouseover="<%= item.getOnMouseOverJS()%>" onmouseout="hidetip()" onclick = "<%= item.getOnClickJSFunc()%>"><%= item.getText4Html()%></a>&nbsp;</div><%= item.getItemExt()%>
                        <%
                        }
                        else
                        {
                        %>
                        <div <%= divStyle%> onmouseover="<%= item.getOnMouseOverJS()%>" onmouseout="hidetip()">&nbsp;<%= item.getText4Html()%>&nbsp;</div><%= item.getItemExt()%>
                        <%
                        }
                        %>
                    </td>
                    <%
            }//  合计 for 
            %>
            </tr>    
            <%
        }

                
    }
    logger.debug("  -- 完毕 ");
%>
    <input type="hidden" name="serviceURL">
</form>
<script>
    // 鼠标飘过高亮
    function trLowLightWhenMouseOver(cb)
    {
        eval("highLight4Mouse(tr_" + cb + ")");
        
    }

    function trHighLightWhenMouseOut(cb)
    {
        eval("lowLight4Mouse(tr_" + cb + ")");
    }
    
    // 高亮度显示
    function trhighOrLowLight(cb)
    {
        try
        {
            var tempTr = null ;
            eval("tempTr = tr_" + cb + ";");
            if(highLineTr != tempTr)
            {
                try
                {
                    lowLight(highLineTr);
                }
                catch(er)
                {

                }
                highLight(tempTr);
            }
            else
            {
                lowLight(highLineTr);
            }
        }
        catch(err)
        {
            alert(err);
        }
        try
        {
            for(var i = 0; i < document.detailForm.tags('INPUT').length; i ++)
            {
                    if(document.detailForm.tags('INPUT')[i].type == "checkbox" 
                    && document.detailForm.tags('INPUT')[i].id == ("checkbox_" + cb))
                    {
                        document.detailForm.tags('INPUT')[i].checked = !document.detailForm.tags('INPUT')[i].checked;
                        checkIdBox(document.detailForm.tags('INPUT')[i]);
                        return;
                    }
            }
        }
        catch(err)
        {
            alert(err);
        }
        
    }
    
    // 是否多选
    var multiSelected = false;

    // ids checkbox
    function checkIdBox(cb)
    {
        try
        {
            if(cb.checked == true)
            {
                for(var i = 0; i < document.detailForm.tags('INPUT').length; i ++)
                {
                    if(document.detailForm.tags('INPUT')[i].type == "checkbox" 
                    && document.detailForm.tags('INPUT')[i].name == "ids")
                    {
                        // 单选
                        if(!multiSelected)
                        {
                            document.detailForm.tags('INPUT')[i].checked = false;
                            eval("lowLight(tr_" + document.detailForm.tags('INPUT')[i].value + ");");
                        }
                        else
                        {
                            if(document.detailForm.tags('INPUT')[i].checked)
                            {
                                eval("highLight(tr_" + document.detailForm.tags('INPUT')[i].value + ");");
                            }
                            else
                            {
                                eval("lowLight(tr_" + document.detailForm.tags('INPUT')[i].value + ");");
                            }
                        }
                    }
                }
                cb.checked = true;
                eval("highLight(tr_" + cb.value + ");");
                try
                {
                    // 选中
                    checkboxChecked(cb.value)
                }
                catch(err)
                {
                }
            }
            else
            {
                eval("lowLight(tr_" + cb.value + ");");
                try
                {
                    // 取消选中
                    checkboxUnChecked(cb.value)
                }
                catch(err)
                {
                }
            }
        }
        catch(err)
        {
            alert(err);
        }
    }

    function getCheckedId()
    {
        for(var i = 0; i < document.detailForm.tags('INPUT').length; i ++)
        {
            if(document.detailForm.tags('INPUT')[i].type == "checkbox" 
            && document.detailForm.tags('INPUT')[i].name == "ids")
            {
                if(document.detailForm.tags('INPUT')[i].checked == true)
                    return document.detailForm.tags('INPUT')[i].value;
            }
        }
        return null;
    }

    // 全选
    function selectAll(obj)
    {
        for(var i = 0; i < document.detailForm.tags('INPUT').length; i ++)
        {
            if(document.detailForm.tags('INPUT')[i].type == "checkbox" 
            && document.detailForm.tags('INPUT')[i].name == "ids")
            {
                document.detailForm.tags('INPUT')[i].checked = obj.checked;
                if(obj.checked)
                {
                    eval("highLight(tr_" + document.detailForm.tags('INPUT')[i].value + ");");
                }
                else
                {
                    eval("lowLight(tr_" + document.detailForm.tags('INPUT')[i].value + ");");
                }
            }
        }
    }

    // 是否有选中的
    function hasSelected(objName)
    {
        var count = 0;
        for(var i = 0; i < detailForm.tags('INPUT').length; i ++)
        {
            if(detailForm.tags('INPUT')[i].type == "checkbox" 
            && detailForm.tags('INPUT')[i].name == objName
            && detailForm.tags('INPUT')[i].checked)
            {
                count ++;
            }
        }
        if( count > 0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
</script>
<%! private int printItemLength(Item item)
    {
         return (item.getLength() * 13 + 30 );
    }
%>
<%@ include file ="/common/List/_changePri_init.jsp"%>
